USE [CallCenter]
GO

/****** Object:  StoredProcedure [dbo].[sp_update_profile_sales]    Script Date: 07/16/2013 00:22:16 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO


-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[sp_update_profile_sales] 
	-- Add the parameters for the stored procedure here
	@SaleID int,
	@firstname varchar(50), 
	@lastname varchar(50),
	@phonenumber varchar(50),
	@cell varchar(50),
	@email varchar(50),
	@emailpassword varchar(50),
	@username varchar(50),
	@password varchar(50),
	@newSaleID int
	
AS
BEGIN
	DECLARE @active bit
	IF(@newSaleID <> -1)
	BEGIN
		EXEC dbo.sp_transfer_all_prospects @SaleID,@newSaleID
		SET @active = 0
	END
	ELSE 
		SET @active = 1
	UPDATE Sales
	SET FirstName = @firstname, LastName = @lastname, PhoneNumber = @phonenumber, CellNumber = @cell, Email = @email, EmailPassword = @emailpassword, UserName = @username, Password = @password, Active = @active
	WHERE SaleID = @SaleID
END


GO

